package com.proton.carepatchtemp.utils.net;

import android.support.annotation.IntRange;
import android.text.TextUtils;

import com.android.volley.Response;
import com.apkfuns.logutils.LogUtils;
import com.google.gson.reflect.TypeToken;
import com.proton.carepatchtemp.application.VCare;
import com.proton.carepatchtemp.constant.Codes;
import com.proton.carepatchtemp.constant.Extras;
import com.proton.carepatchtemp.database.AliyunToken;
import com.proton.carepatchtemp.database.TestManager;
import com.proton.carepatchtemp.database.dao.AddReportInfo;
import com.proton.carepatchtemp.database.table.Note;
import com.proton.carepatchtemp.database.table.Report;
import com.proton.carepatchtemp.database.table.RptConfig;
import com.proton.carepatchtemp.utils.FormUtils;
import com.proton.carepatchtemp.utils.JSONUtils;
import com.proton.carepatchtemp.utils.NetUtils;
import com.proton.carepatchtemp.utils.eventbus.MainEvent;
import com.proton.carepatchtemp.utils.net.oss.OSSUtils;
import com.proton.carepatchtemp.utils.net.pair.ParamPair;
import com.proton.carepatchtemp.utils.net.pair.ResultPair;
import com.proton.carepatchtemp.utils.net.request.JGet;
import com.proton.carepatchtemp.utils.net.request.JPost;
import com.proton.carepatchtemp.utils.ui.ToastUtils;
import com.sdsmdg.tastytoast.TastyToast;

import org.greenrobot.eventbus.EventBus;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * Created by MoonlightSW on 2016/10/6.
 */

public class ReportCenter extends DataCenter {
    //  每一页report条数
    public static final int PS_RPT = 10;  //每次请求的数据条数
    public static final String getlist = "/report/getList";
    public static final String add = "/tempreport/add"; //新建报告
    public static final String edit = "/reporttemp/edit";  //   上传报告
    public static final String getPrfReport = "/profile/getreportlist"; //  获取档案报告
    public static final String delete = "/report/delete";
    public static final String share = "/report/share";
    public static final String collect = "/report/collect";
    public static final String cancelcollect = "/report/cancelcollect";
    //  上拉加载更多，下拉刷新
    public static final String getNewList = "/report/getnewTemplists";
    //  获取报告随手记
    public static final String getcommentlist = "/report/getcommentlist";
    //  添加报告随手记
    public static final String addcomment = "/report/addcomment";
    //  添加多条随手记
    public static final String addComments = "/report/addcomments";
    //删除随手记
    public static final String deletecomment = "/report/deletecomment";
    //获取档案下收藏的报告
    public static final String getPrfCollectRPT = "/profile/getCollectReportlist";
    public static final String aliyunToken = "/user/getSTSAuthorization";

    public static boolean getPrfReportList(final String profileId, final int page, final int pageSize) {
        if (NetUtils.noNet()) {
            EventBus.getDefault().post(new MainEvent(Codes.REPORT_PRF_RPT_LIST, Extras.RET_F));
            return false;
        }


        List params = new ArrayList();
        params.add(new ParamPair(Extras.PRF_PROFILEID, profileId));
        params.add(new ParamPair(Extras.PG, page));
        params.add(new ParamPair(Extras.PS, PS_RPT));

        VolleyUtil.addRequest(new JGet(getApi(getPrfReport), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();

                MainEvent mainEvent = null;
                if (response.isSuccess()) {
                    LogUtils.e("Lijin Test get list msg = " + msg);
                    Type listType = new TypeToken<ArrayList<Report>>() {
                    }.getType();

                    List<Report> rpts = JSONUtils.getObj(msg, listType, "yyyy-MM-dd");
                    if (null != rpts || rpts.size() > 0) {
                        LogUtils.e(rpts.size());
                        for (Report rpt : rpts) {

                        }
//                        DbUtils.batchTask(new RptDao(), rpts);  //将数据添加到本地数据库
                        mainEvent = new MainEvent(Codes.REPORT_PRF_RPT_LIST, ret, String.valueOf(page), rpts);
                        EventBus.getDefault().post(mainEvent);
//                        mainEvent.post();
                        LogUtils.e("post Rpts");
                    } else {
                        LogUtils.e("rpts is null");
//                        mainEvent = new MainEvent(code,Extras.RET_END,"没有更多了","-1");
                    }
                } else {
                    mainEvent = new MainEvent(Codes.REPORT_PRF_RPT_LIST, ret, String.valueOf(page));
                    EventBus.getDefault().post(mainEvent);
//                    mainEvent = new MainEvent(Codes.NET_RPT_GETLIST,ret,msg);
                }
//                if(mainEvent != null) mainEvent.post();
            }
        }));
        return false;
    }

    public static boolean getPrfCollectRPTList(final String profileId, final int page, final int pageSize) {
        if (NetUtils.noNet()) {
            EventBus.getDefault().post(new MainEvent(Codes.REPORT_PRF_RPT_LIST, Extras.RET_F));
            return false;
        }


        List params = new ArrayList();
        params.add(new ParamPair(Extras.PRF_PROFILEID, profileId));
        params.add(new ParamPair(Extras.PG, page));
        params.add(new ParamPair(Extras.PS, PS_RPT));

        VolleyUtil.addRequest(new JGet(getApi(getPrfCollectRPT), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();

                MainEvent mainEvent = null;
                if (response.isSuccess()) {
                    LogUtils.e("Lijin Test get list msg = " + msg);
                    Type listType = new TypeToken<ArrayList<Report>>() {
                    }.getType();

                    List<Report> rpts = JSONUtils.getObj(msg, listType, "yyyy-MM-dd");
                    if (null != rpts || rpts.size() > 0) {
                        LogUtils.e(rpts.size());
                        for (Report rpt : rpts) {

                        }
//                        DbUtils.batchTask(new RptDao(), rpts);  //将数据添加到本地数据库
                        mainEvent = new MainEvent(Codes.REPORT_PRF_RPT_LIST, ret, String.valueOf(page), rpts);
                        EventBus.getDefault().post(mainEvent);
//                        mainEvent.post();
                        LogUtils.e("post Rpts");
                    } else {
                        LogUtils.e("rpts is null");
//                        mainEvent = new MainEvent(code,Extras.RET_END,"没有更多了","-1");
                    }
                } else {
                    mainEvent = new MainEvent(Codes.REPORT_PRF_RPT_LIST, ret, String.valueOf(page));
                    EventBus.getDefault().post(mainEvent);
//                    mainEvent = new MainEvent(Codes.NET_RPT_GETLIST,ret,msg);
                }
//                if(mainEvent != null) mainEvent.post();
            }
        }));
        return false;
    }

    /**
     * @param page 第几页
     */
    public static boolean getlist(final int page, @IntRange(from = Extras.RPT_TYPE_ALL, to = Extras.RPT_TYPE_SHARE) final int oldtype, boolean force) {
        final int type = oldtype > Extras.RPT_TYPE_SHARE || oldtype < Extras.RPT_TYPE_ALL ? Extras.RPT_TYPE_ALL : oldtype;
//        final int code = Codes.NET_RPT_GETLIST;
        if (NetUtils.noNet()) {
            EventBus.getDefault().post(new MainEvent(Codes.REPORT_DATA_LIST, Extras.RET_F));
            return false;
        }

        List params = new ArrayList();
        params.add(new ParamPair(Extras.PG, page));
        params.add(new ParamPair(Extras.PS, PS_RPT));

        params.add(new ParamPair(Extras.TYPE, type));
        params.add(new ParamPair(Extras.ONLYSHARE, Extras.RPT_ONLYSHARE_FALSE));

        VolleyUtil.addRequest(new JGet(getApi(getlist), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();

                MainEvent mainEvent = null;
                if (response.isSuccess()) {
                    LogUtils.e("Lijin Test get list msg = " + msg);
                    Type listType = new TypeToken<ArrayList<Report>>() {
                    }.getType();

                    List<Report> rpts = JSONUtils.getObj(msg, listType, "yyyy-MM-dd");
                    if (null != rpts || rpts.size() > 0) {
                        LogUtils.e(rpts.size());
                        for (Report rpt : rpts) {
//                            rpt.getData() = GsonUtils.getGson().toJson(rpt.mRptData);
//                            if (rpt.getVcareadvice().equals("") || rpt.getVcareresult().equals("")) {
//                                continue;
//                            }

                            //LogUtils.e("getList");
//                            DataStore.listFeaecg.add(rpt.getId()+"__"+rpt.getVcareadvice());
//                            DataStore.listFeaecg2nd.add(rpt.getId()+"__"+rpt.getVcareresult());
//                            DataStore.listRptId.add(String.valueOf(rpt.getId()));
                        }
//                        DbUtils.batchTask(new RptDao(), rpts);  //将数据添加到本地数据库
                        mainEvent = new MainEvent(Codes.REPORT_DATA_LIST, rpts);
                        EventBus.getDefault().post(mainEvent);
//                        mainEvent.post();
                        LogUtils.e("post Rpts");
                    } else {
                        LogUtils.e("rpts is null");
//                        mainEvent = new MainEvent(code,Extras.RET_END,"没有更多了","-1");
                    }
                } else {
//                    mainEvent = new MainEvent(Codes.NET_RPT_GETLIST,ret,msg);
                }
//                if(mainEvent != null) mainEvent.post();
            }
        }));
        return false;
    }

    /**
     * @param endTime 本地最新报告时间
     * @param page    默认为1(第几页)
     * @param oldtype 请求的报告类型：温度是1 心电是2
     * @param poll    0 是上拉 1是 下拉
     */
    public static boolean getNewList(String endTime,
                                     final int page,
                                     @IntRange(from = Extras.RPT_TYPE_ALL, to = Extras.RPT_TYPE_SHARE) final int oldtype,
                                     final int poll,
                                     final int isCollect,
                                     boolean force) {

        final int type = oldtype > Extras.RPT_TYPE_SHARE || oldtype < Extras.RPT_TYPE_ALL ? Extras.RPT_TYPE_ALL : oldtype;
//        final int code = Codes.NET_RPT_GETLIST;
        if (NetUtils.noNet()) {
            EventBus.getDefault().post(new MainEvent(Codes.REPORT_DATA_UPLIST, Extras.RET_F));
            return false;
        }

        List params = new ArrayList();
        params.add(new ParamPair(Extras.ENDTIME, endTime));
        params.add(new ParamPair(Extras.PG, page));
        params.add(new ParamPair(Extras.PS, PS_RPT));
        params.add(new ParamPair(Extras.TYPE, type));
        params.add(new ParamPair(Extras.RPT_COLLECT, isCollect));
        params.add(new ParamPair(Extras.RPT_POLL, poll));
        LogUtils.d(params);
        VolleyUtil.addRequest(new JGet(getApi(getNewList), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();
                LogUtils.d("GetNewList onResponse in thread id = " + Thread.currentThread().getId());
                MainEvent mainEvent = null;
                if (response.isSuccess()) {
                    LogUtils.d(msg);
                    Type listType = new TypeToken<ArrayList<Report>>() {
                    }.getType();

                    List<Report> rpts = JSONUtils.getObj(msg, listType, "yyyy-MM-dd");
                    if (null != rpts || rpts.size() > 0) {
                        for (Report rpt : rpts) {
//                            rpt.getData() = GsonUtils.getGson().toJson(rpt.mRptData);
//                            if (rpt.getVcareadvice().equals("") || rpt.getVcareresult().equals("")) {
//                                continue;
//                            }

                            //LogUtils.e("getList");
//                            DataStore.listFeaecg.add(rpt.getId()+"__"+rpt.getVcareadvice());
//                            DataStore.listFeaecg2nd.add(rpt.getId()+"__"+rpt.getVcareresult());
//                            DataStore.listRptId.add(String.valueOf(rpt.getId()));
                        }
//                        DbUtils.batchTask(new RptDao(), rpts);  //将数据添加到本地数据库
                        if (0 == poll) {
                            mainEvent = new MainEvent(Codes.REPORT_DATA_UPLIST, rpts);
                        } else if (1 == poll) {
                            mainEvent = new MainEvent(Codes.REPORT_DATA_DOWNLIST, rpts);
                        }
                        LogUtils.d(rpts);
                        EventBus.getDefault().post(mainEvent);
//                        mainEvent.post();
                    } else {
                        LogUtils.d("rpts is null");
//                        mainEvent = new MainEvent(code,Extras.RET_END,"没有更多了","-1");
                    }
                } else {
                    LogUtils.e("Get Reports Failed!");
//                    mainEvent = new MainEvent(Codes.NET_RPT_GETLIST,ret,msg);
                }
//                if(mainEvent != null) mainEvent.post();
            }
        }));
        return false;
    }

    /**
     * @param reportid 增加随手记报告的id
     * @param type     报告类型 1 = 药物     2 = 降温   3 =  其他     4 = ECG感受      5 = ECG药物    6 = 生活环境
     * @return 是否增加成功成功
     */
    public static boolean addComment(final String reportid, int type, String content) {
        final boolean[] delRet = {false};
        if (DataCenter.noNet()) {
            EventBus.getDefault().post(new MainEvent(Codes.REPORT_DATA_UPLIST, Extras.RET_F));
            return false;
        }
        List params = new ArrayList();
        params.add(new ParamPair(Extras.REPORTID, reportid));
        params.add(new ParamPair(Extras.NOTE_TYPE, type));
        params.add(new ParamPair(Extras.NOTE_CONTENT, content));
        VolleyUtil.addRequest(new JPost(getApi(addcomment), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();
                if (response.isSuccess()) {
                    LogUtils.e("Add note report = " + reportid + "      Add note result = " + ret + "     Add note msg = " + msg);
                    EventBus.getDefault().post(new MainEvent(Codes.REPORT_ADD_NOTE, ret, msg));
                } else {
                    ToastUtils.e("添加随手记失败！" + msg);
                    LogUtils.e(msg);
                }

            }
        }));
        return delRet[0];
    }

    public static boolean addComments(final Long reportid, String jsonContent) {
        final boolean[] delRet = {false};
        if (DataCenter.noNet()) {
            EventBus.getDefault().post(new MainEvent(Codes.REPORT_DATA_UPLIST, Extras.RET_F));
            return false;
        }
        List params = new ArrayList();
        params.add(new ParamPair(Extras.REPORTID, reportid));
        params.add(new ParamPair(Extras.NOTE_JSON_CONTENT, jsonContent));
        VolleyUtil.addRequest(new JPost(getApi(addComments), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();
                if (response.isSuccess()) {
                    LogUtils.e("Add note report = " + reportid + "      Add note result = " + ret + "     Add note msg = " + msg);
                    EventBus.getDefault().post(new MainEvent(Codes.REPORT_ADD_NOTE, ret, msg));
                } else {
                    ToastUtils.e("添加随手记失败！" + msg);
                    LogUtils.e(msg);
                }
            }
        }));
        return delRet[0];
    }

    /**
     * @param reportid
     * @return
     */
    public static boolean getCommentList(final String reportid) {
        final boolean[] delRet = {false};
        if (DataCenter.noNet()) return false;
        List params = new ArrayList();
        params.add(new ParamPair(Extras.REPORTID, reportid));
        VolleyUtil.addRequest(new JGet(getApi(getcommentlist), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();
//                LogUtils.e("Delete reports = " + reportid + "      Delete reports result = " + ret + "     Delete msg = " + msg);
                if (response.isSuccess()) {
                    //LogUtils.e(msg);
                    Type listType = new TypeToken<ArrayList<Note>>() {
                    }.getType();

                    List<Note> notes = JSONUtils.getObj(msg, listType, "yyyy-MM-dd");
                    if (null != notes || notes.size() > 0) {
//                        LogUtils.e(notes.size());
                        for (Note note : notes) {
//                            rpt.getData() = GsonUtils.getGson().toJson(rpt.mRptData);
                            if (TextUtils.isEmpty(note.getContent())) {
                                continue;
                            }

                            //LogUtils.e("getList");
//                            DataStore.listFeaecg.add(rpt.getId()+"__"+rpt.getVcareadvice());
//                            DataStore.listFeaecg2nd.add(rpt.getId()+"__"+rpt.getVcareresult());
//                            DataStore.listRptId.add(String.valueOf(rpt.getId()));
                        }
//                        DbUtils.batchTask(new RptDao(), rpts);  //将数据添加到本地数据库
                        MainEvent mainEvent = new MainEvent(Codes.REPORT_GET_NOTES, ret, notes);
                        EventBus.getDefault().post(mainEvent);
                    }
                } else {
                    EventBus.getDefault().post(new MainEvent(Codes.REPORT_GET_NOTES, ret));
                }
            }
        }));
        return delRet[0];
    }


    /**
     * @param reportids 删除报告的id ，多个用逗号隔开
     * @return 是否删除成功
     */
    public static boolean deleteSome(final String reportids) {
        final boolean[] delRet = {false};
        if (DataCenter.noNet()) return false;
        List params = new ArrayList();
        params.add(new ParamPair(Extras.REPORTIDS, reportids));
        VolleyUtil.addRequest(new JPost(getApi(delete), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();
                LogUtils.e("Delete reports = " + reportids + "      Delete reports result = " + ret + "     Delete msg = " + msg);
                EventBus.getDefault().post(new MainEvent(Codes.NET_RPT_DELETE, ret, msg));
            }
        }));
        return delRet[0];
    }

    /**
     * @param reportid 报告id
     * @return 是否成功
     */
    public static boolean collect(final long reportid) {
        final boolean[] collectRet = {false};
        if (DataCenter.noNet()) return false;
        List params = new ArrayList();
        params.add(new ParamPair(Extras.REPORTID, reportid));
        VolleyUtil.addRequest(new JPost(getApi(collect), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();
                LogUtils.e("Collect report = " + reportid + "      Collect report result = " + ret + "     Collect msg = " + msg);
                if ("SUCCESS".equalsIgnoreCase(ret)) {
                    TastyToast.makeText(VCare.get(), "收藏报告成功！", TastyToast.LENGTH_SHORT, TastyToast.SUCCESS);
                } else {
                    TastyToast.makeText(VCare.get(), "收藏报告失败！", TastyToast.LENGTH_SHORT, TastyToast.ERROR);
                }
            }
        }));
        return collectRet[0];
    }

    /**
     * @param reportid 报告id
     * @return 返回结果
     */
    public static boolean cancelCollect(final long reportid) {
        final boolean[] collectRet = {false};
        if (DataCenter.noNet()) return false;
        List params = new ArrayList();
        params.add(new ParamPair(Extras.REPORTID, reportid));
        VolleyUtil.addRequest(new JPost(getApi(cancelcollect), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();
                LogUtils.e("CancelCollect report = " + reportid + "      CancelCollect report result = " + ret + "     CancelCollect msg = " + msg);
                if ("SUCCESS".equalsIgnoreCase(ret)) {
                    TastyToast.makeText(VCare.get(), "取消收藏成功！", TastyToast.LENGTH_SHORT, TastyToast.SUCCESS);
                } else {
                    TastyToast.makeText(VCare.get(), "取消收藏失败！", TastyToast.LENGTH_SHORT, TastyToast.ERROR);
                }
            }
        }));
        return collectRet[0];
    }

    public static boolean add(AddReportInfo mAddReportInfo) {
        if (NetUtils.noNet()) {
            return false;
        }
        List params = new ArrayList();
        params.add(new ParamPair(Extras.RPT_DEVICEID, mAddReportInfo.getDeviceid()));
        params.add(new ParamPair(Extras.PRF_PROFILEID, mAddReportInfo.getProfileid()));
        params.add(new ParamPair(Extras.RPT_STARTTIME, FormUtils.formatTime(new Date(mAddReportInfo.getStoreStartTime()))));
        params.add(new ParamPair(Extras.TYPE, mAddReportInfo.getType()));
        VolleyUtil.addRequest(new JPost(getApi(add), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();
                Report mReport = null;
                if (response.isSuccess()) {
                    mReport = JSONUtils.getObj(msg, Report.class, "yyyy-MM-dd");
                    EventBus.getDefault().post(new MainEvent(mAddReportInfo.getMacAddress(), Codes.NET_ADD_REPORT, ret, null, null));
                    TestManager.setReport(mAddReportInfo.getMacAddress(), mReport);
                } else {
                    EventBus.getDefault().post(new MainEvent(mAddReportInfo.getMacAddress(), Codes.NET_ADD_REPORT, ret, null, null));
                }
                LogUtils.e(msg);
            }
        }));
        return false;
    }

    public static boolean edit(AddReportInfo mAddReportInfo) {
        if (NetUtils.noNet()) {
            return false;
        }
        List params = new ArrayList();
        params.add(new ParamPair(Extras.REPORTID, mAddReportInfo.getReportId()));
        params.add(new ParamPair(Extras.RPT_DEVICEID, mAddReportInfo.getDeviceid()));
        params.add(new ParamPair(Extras.RPT_FILEPATH, OSSUtils.getSaveUrl(mAddReportInfo.getFilepath())));
        params.add(new ParamPair(Extras.PRF_PROFILEID, mAddReportInfo.getProfileid()));
        params.add(new ParamPair(Extras.RPT_STARTTIME, FormUtils.formatTime(new Date(mAddReportInfo.getStoreStartTime()))));
        params.add(new ParamPair(Extras.RPT_ENDTIME, FormUtils.formatTime(new Date(mAddReportInfo.getStoreEndTime()))));
        params.add(new ParamPair(Extras.TYPE, mAddReportInfo.getType()));
        params.add(new ParamPair(Extras.RPT_CONFIG, new RptConfig().toString()));
        params.add(new ParamPair(Extras.RPT_DATA, mAddReportInfo.getData()));
        VolleyUtil.addRequest(new JPost(getApi(edit), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();
                Report mReport = null;
                if (response.isSuccess()) {
                    mReport = JSONUtils.getObj(msg, Report.class, "yyyy-MM-dd");
                    EventBus.getDefault().post(new MainEvent(Codes.REPORT_EDIT, ret, mReport.getId() + "", mReport));
                } else {
                    EventBus.getDefault().post(new MainEvent(Codes.REPORT_EDIT, ret, msg));
                }
            }
        }));
        return false;
    }

    public static boolean deletecomment(long commentid) {
        if (NetUtils.noNet()) {
            return false;
        }
        List params = new ArrayList();
        params.add(new ParamPair(Extras.COMMENTID, commentid));
        VolleyUtil.addRequest(new JPost(getApi(deletecomment), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String ret = response.getName();
                String msg = response.getValue();
                if (response.isSuccess()) {
                    LogUtils.e(msg);
                }
                EventBus.getDefault().post(new MainEvent(Codes.REPORT_DELETE_NOTES, ret, msg));
            }
        }));
        return false;
    }

    /**
     * 获取阿里云token
     */
    public static void getAliyunToken() {
        if (TextUtils.isEmpty(VCare.get().getToken())) {
            return;
        }
        List params = new ArrayList();
        VolleyUtil.addRequest(new JPost(getApi(aliyunToken), params, new Response.Listener<ResultPair>() {
            @Override
            public void onResponse(ResultPair response) {
                String msg = response.getValue();
                if (response.isSuccess()) {
                    LogUtils.e(msg);
                    LogUtils.e("获取阿里云token成功");
                }
                VCare.get().aliyunToken = JSONUtils.getObj(response.getValue(), AliyunToken.class);
            }
        }));
    }

}
